package cn.com.anysdk.redis.exception;

/**
 * Redis连接异常
 */
public class RedisConnectionException extends RedisException {
    
    private static final String ERROR_CODE_PREFIX = "REDIS_CONNECTION_";
    
    public RedisConnectionException(String message) {
        super(message, ERROR_CODE_PREFIX + "ERROR");
    }
    
    public RedisConnectionException(String message, String errorCode) {
        super(message, ERROR_CODE_PREFIX + errorCode);
    }
    
    public RedisConnectionException(String message, Throwable cause) {
        super(message, cause, ERROR_CODE_PREFIX + "ERROR");
    }
    
    public RedisConnectionException(String message, Throwable cause, String errorCode) {
        super(message, cause, ERROR_CODE_PREFIX + errorCode);
    }
    
    /**
     * 网络异常
     */
    public static class NetworkException extends RedisConnectionException {
        public NetworkException(String message) {
            super(message, "NETWORK");
        }
        
        public NetworkException(String message, Throwable cause) {
            super(message, cause, "NETWORK");
        }
    }
    
    /**
     * 认证失败异常
     */
    public static class AuthenticationException extends RedisConnectionException {
        public AuthenticationException(String message) {
            super(message, "AUTH");
        }
        
        public AuthenticationException(String message, Throwable cause) {
            super(message, cause, "AUTH");
        }
    }
    
    /**
     * 连接超时异常
     */
    public static class TimeoutException extends RedisConnectionException {
        public TimeoutException(String message) {
            super(message, "TIMEOUT");
        }
        
        public TimeoutException(String message, Throwable cause) {
            super(message, cause, "TIMEOUT");
        }
    }
}